<?php
  class m_menu extends Model{
      function getModule(){
          $data = $this->db->query("select * from module");
          $result=array();
          if($data->num_rows() > 0){
              $i=0;
              foreach ($data->result() as $row){
                  $result[$i]['module'] = $row;
                  $data2 = $this->db->query("select * from sub_module where status = '1' and id_module = '$row->id' order by no_urut");
                  if($data2->num_rows() > 0){
                      foreach ($data2->result() as $row2){
                          $result[$i]['subModule'][] = $row2;
                      }
                  }else{
                      $result[$i]['subModule']= array();
                  }
                  $i++;
              }
          }
          return $result;
      }
  }
?>
